using System;
using System.Collections.Generic;
using Data;
using UnityEngine;

public class EditDrawCtrl : MonoBehaviour
{
	private void Start()
	{
		this.DefaultBoardMake();
		for (int i = 1; i < this.filters.Length; i++)
		{
			MultiColorExt.SetColor(this.filters[i], i - 1);
		}
		this.UpdateColorCheck();
	}

	private void Update()
	{
		if (UnityEngine.Input.GetKey(KeyCode.Mouse0))
		{
			Vector3 mousePosition = Vector3.zero;
			mousePosition = UnityEngine.Input.GetTouch(0).position;
			this.OnMouseLeftDrag(mousePosition);
		}
		else if (UnityEngine.Input.GetKey(KeyCode.Mouse1))
		{
			Vector3 mousePosition2 = Vector3.zero;
			mousePosition2 = UnityEngine.Input.GetTouch(0).position;
			this.OnMouseRightDrag(mousePosition2);
		}
		else if (UnityEngine.Input.GetKey(KeyCode.Mouse2))
		{
			Vector3 mousePosition3 = Vector3.zero;
			mousePosition3 = UnityEngine.Input.GetTouch(0).position;
			this.OnMouseWhillDrag(mousePosition3);
		}
		else if (UnityEngine.Input.GetKey(KeyCode.J))
		{
			if (this.currentColor >= -1)
			{
				this.currentColor--;
				this.UpdateColorCheck();
			}
		}
		else if (UnityEngine.Input.GetKey(KeyCode.K) && this.currentColor < this.colorObjs.Length - 2)
		{
			this.currentColor++;
			this.UpdateColorCheck();
		}
	}

	private void UpdateColorCheck()
	{
		for (int i = 0; i < this.colorObjs.Length; i++)
		{
			this.colorObjs[i].SetActive(false);
		}
		this.colorObjs[this.currentColor + 1].SetActive(true);
	}

	private void OnClickColor(tk2dUIItem item)
	{
		this.currentColor = Convert.ToInt32(item.gameObject.name);
		this.UpdateColorCheck();
	}

	private void OnMouseLeftDrag(Vector3 mousePosition)
	{
		Vector3 vector = this.viewCamera.ScreenToWorldPoint(mousePosition);
		vector -= base.transform.localPosition;
		Point point = BlocksCoordinate.coordinate.editCoordinate.WorldToPuzzle(vector);
		bool isUp = (point.x + point.y) % 2 == 0;
		int num = this.editInfo.FindIndex((EditDrawCtrl.EditInfo item) => item.point == point);
		if (point.x > BlocksCoordinate.coordinate.editCoordinate.width - 1 || point.x < 0 || point.y > BlocksCoordinate.coordinate.editCoordinate.height - 1 || point.y < 0)
		{
			return;
		}
		if (this.editInfo.Count > 0 && num >= 0 && !this.editInfo[num].isHinder && num >= 0 && this.editInfo[num].color == this.currentColor)
		{
			return;
		}
		if (this.editInfo.Count > 0 && num >= 0 && this.editInfo[num].isHinder)
		{
			this.DeleteIndex(num);
		}
		else if (num >= 0 && this.editInfo[num].color != this.currentColor)
		{
			this.DeleteIndex(num);
		}
		Vector3 a = BlocksCoordinate.coordinate.editCoordinate.PuzzleToWorld((float)point.x, (float)point.y);
		a.z = 0f;
		BoardWidgetHandler boardWidgetHandler = Widget.Create<BoardWidgetHandler>();
		boardWidgetHandler.transform.parent = this.boardBg.transform;
		boardWidgetHandler.transform.localPosition = a + Vector3.back * 1f;
		boardWidgetHandler.transform.localScale = Vector3.one * BlocksCoordinate.coordinate.editCoordinate.size;
		boardWidgetHandler.SetData(isUp, point, new byte[2], this.currentColor, true);
		boardWidgetHandler.name = "board";
		EditDrawCtrl.EditInfo editInfo = new EditDrawCtrl.EditInfo();
		editInfo.point = point;
		editInfo.isHinder = false;
		editInfo.boardWidget = boardWidgetHandler;
		editInfo.color = this.currentColor;
		this.editInfo.Add(editInfo);
		this.UpdateCurrentTileCount();
	}

	private void OnMouseRightDrag(Vector3 mousePosition)
	{
		Vector3 vector = this.viewCamera.ScreenToWorldPoint(mousePosition);
		vector -= base.transform.localPosition;
		Point point = BlocksCoordinate.coordinate.editCoordinate.WorldToPuzzle(vector);
		if (this.editInfo.Count <= 0 || this.editInfo.FindIndex((EditDrawCtrl.EditInfo item) => item.point == point) < 0)
		{
			return;
		}
		int index = this.editInfo.FindIndex((EditDrawCtrl.EditInfo item) => item.point == point);
		this.DeleteIndex(index);
	}

	private void OnMouseWhillDrag(Vector3 mousePosition)
	{
		Vector3 vector = this.viewCamera.ScreenToWorldPoint(mousePosition);
		vector -= base.transform.localPosition;
		Point point = BlocksCoordinate.coordinate.editCoordinate.WorldToPuzzle(vector);
		int num = this.editInfo.FindIndex((EditDrawCtrl.EditInfo item) => item.point == point);
		if (point.x > BlocksCoordinate.coordinate.editCoordinate.width - 1 || point.x < 0 || point.y > BlocksCoordinate.coordinate.editCoordinate.height - 1 || point.y < 0)
		{
			return;
		}
		if (this.editInfo.Count > 0 && num >= 0 && this.editInfo[num].isHinder)
		{
			return;
		}
		if (this.editInfo.Count > 0 && num >= 0 && !this.editInfo[num].isHinder)
		{
			this.DeleteIndex(num);
		}
		Vector3 localPosition = BlocksCoordinate.coordinate.editCoordinate.PuzzleToWorld((float)point.x, (float)point.y);
		localPosition.z = 0f;
		HinderWidgetHandler hinderWidgetHandler = Widget.Create<HinderWidgetHandler>();
		hinderWidgetHandler.transform.parent = this.boardBg.transform;
		hinderWidgetHandler.transform.localPosition = localPosition;
		hinderWidgetHandler.transform.localScale = Vector3.one * BlocksCoordinate.coordinate.editCoordinate.size;
		hinderWidgetHandler.name = "hinder";
		bool isUp = (point.x + point.y) % 2 == 0;
		int tangramIndex = (point.x + ((point.y % 2 != 0) ? 2 : 0)) % 4;
		hinderWidgetHandler.SetData(isUp, tangramIndex);
		EditDrawCtrl.EditInfo editInfo = new EditDrawCtrl.EditInfo();
		editInfo.point = point;
		editInfo.isHinder = true;
		editInfo.hinderWidget = hinderWidgetHandler;
		this.editInfo.Add(editInfo);
		this.UpdateCurrentTileCount();
	}

	private void DeleteIndex(int index)
	{
		if (this.editInfo[index].boardWidget != null)
		{
			UnityEngine.Object.Destroy(this.editInfo[index].boardWidget.gameObject);
		}
		if (this.editInfo[index].hinderWidget != null)
		{
			UnityEngine.Object.Destroy(this.editInfo[index].hinderWidget.gameObject);
		}
		this.editInfo.RemoveAt(index);
		this.UpdateCurrentTileCount();
	}

	private void DefaultBoardMake()
	{
		for (int i = 0; i < BlocksCoordinate.coordinate.editCoordinate.width; i++)
		{
			for (int j = 0; j < BlocksCoordinate.coordinate.editCoordinate.height; j++)
			{
				Vector3 localPosition = BlocksCoordinate.coordinate.editCoordinate.PuzzleToWorld((float)i, (float)j);
				localPosition.z = 0f;
				BoardWidgetHandler item = Widget.Create<BoardWidgetHandler>();
				this.defaultboardWidgets.Add(item);
				this.defaultboardWidgets[this.defaultboardWidgets.Count - 1].transform.parent = this.defualtboardBg.transform;
				this.defaultboardWidgets[this.defaultboardWidgets.Count - 1].transform.localPosition = localPosition;
				this.defaultboardWidgets[this.defaultboardWidgets.Count - 1].transform.localScale = Vector3.one * BlocksCoordinate.coordinate.editCoordinate.size;
				this.defaultboardWidgets[this.defaultboardWidgets.Count - 1].name = "board";
				this.defaultboardWidgets[this.defaultboardWidgets.Count - 1].sprite.color = new Color(1f, 1f, 1f, 0.3f);
				bool isUp = (i + j) % 2 == 0;
				this.defaultboardWidgets[this.defaultboardWidgets.Count - 1].SetData(isUp, new Point(i, j), new byte[2], -1, false);
			}
		}
	}

	public void LoadLevelDraw(Level loadLevelDraw)
	{
		this.ReSet();
		BlockCoordinate blockCoordinate = new TriangleCoordinate();
		if (GameMode.gameMode == GameType.TRIANGLE)
		{
			blockCoordinate = new TriangleCoordinate();
		}
		else if (GameMode.gameMode == GameType.SQUARE)
		{
			blockCoordinate = new SquareCoordinate();
		}
		else if (GameMode.gameMode == GameType.HEXA)
		{
			blockCoordinate = new HexaCoordinate();
		}
		else if (GameMode.gameMode == GameType.RHOMBUS)
		{
			blockCoordinate = new RhombusCoordinate();
		}
		else if (GameMode.gameMode == GameType.TANGRAM)
		{
			blockCoordinate = new TangramCoordinate();
		}
		bool flag = false;
		if (blockCoordinate.height <= loadLevelDraw.height)
		{
			flag = true;
		}
		blockCoordinate.width = loadLevelDraw.width;
		if (!flag)
		{
			blockCoordinate.height = loadLevelDraw.height;
		}
		for (int i = 0; i < loadLevelDraw.blockcount; i++)
		{
			for (int j = 0; j < loadLevelDraw.level[i].Length; j++)
			{
				Point point = blockCoordinate.IndexToPuzzle((int)loadLevelDraw.level[i][j]);
				if (GameMode.gameMode == GameType.TRIANGLE && loadLevelDraw.isReverse)
				{
					point.x++;
				}
				else if ((GameMode.gameMode == GameType.HEXA || GameMode.gameMode == GameType.RHOMBUS) && flag)
				{
					point.x++;
					if (point.x % 2 != 0)
					{
						point.y--;
					}
				}
				else if (GameMode.gameMode == GameType.TANGRAM)
				{
					point.x += (int)loadLevelDraw.editMinPoint[0];
					point.y += (int)loadLevelDraw.editMinPoint[1];
				}
				bool isUp = (point.x + point.y) % 2 == 0;
				Vector3 a = BlocksCoordinate.coordinate.editCoordinate.PuzzleToWorld((float)point.x, (float)point.y);
				a.z = 0f;
				BoardWidgetHandler boardWidgetHandler = Widget.Create<BoardWidgetHandler>();
				boardWidgetHandler.transform.parent = this.boardBg.transform;
				boardWidgetHandler.transform.localPosition = a + Vector3.back * 1f;
				boardWidgetHandler.transform.localScale = Vector3.one * BlocksCoordinate.coordinate.editCoordinate.size;
				int color = -1;
				if (loadLevelDraw.changeColor != null)
				{
					color = (int)loadLevelDraw.changeColor[i][j];
				}
				boardWidgetHandler.SetData(isUp, point, new byte[2], color, true);
				boardWidgetHandler.name = "board";
				EditDrawCtrl.EditInfo editInfo = new EditDrawCtrl.EditInfo();
				editInfo.point = point;
				editInfo.isHinder = false;
				editInfo.boardWidget = boardWidgetHandler;
				editInfo.color = color;
				this.editInfo.Add(editInfo);
			}
		}
		for (int k = 0; k < loadLevelDraw.hinder.Length; k++)
		{
			Point point2 = blockCoordinate.IndexToPuzzle((int)loadLevelDraw.hinder[k]);
			if (GameMode.gameMode == GameType.TRIANGLE && loadLevelDraw.isReverse)
			{
				point2.x++;
			}
			else if ((GameMode.gameMode == GameType.HEXA || GameMode.gameMode == GameType.RHOMBUS) && flag)
			{
				point2.x++;
				if (point2.x % 2 != 0)
				{
					point2.y--;
				}
			}
			else if (GameMode.gameMode == GameType.TANGRAM)
			{
				point2.x += (int)loadLevelDraw.editMinPoint[0];
				point2.y += (int)loadLevelDraw.editMinPoint[1];
			}
			bool isUp2 = (point2.x + point2.y) % 2 == 0;
			int tangramIndex = (point2.x + (int)loadLevelDraw.editMinPoint[0] + (((point2.y + (int)loadLevelDraw.editMinPoint[1]) % 2 != 0) ? 2 : 0)) % 4;
			Vector3 localPosition = BlocksCoordinate.coordinate.editCoordinate.PuzzleToWorld((float)point2.x, (float)point2.y);
			localPosition.z = 0f;
			HinderWidgetHandler hinderWidgetHandler = Widget.Create<HinderWidgetHandler>();
			hinderWidgetHandler.transform.parent = this.boardBg.transform;
			hinderWidgetHandler.transform.localPosition = localPosition;
			hinderWidgetHandler.transform.localScale = Vector3.one * BlocksCoordinate.coordinate.editCoordinate.size;
			hinderWidgetHandler.SetData(isUp2, tangramIndex);
			hinderWidgetHandler.name = "hinder";
			EditDrawCtrl.EditInfo editInfo2 = new EditDrawCtrl.EditInfo();
			editInfo2.point = point2;
			editInfo2.isHinder = true;
			editInfo2.hinderWidget = hinderWidgetHandler;
			this.editInfo.Add(editInfo2);
		}
		this.UpdateCurrentTileCount();
	}

	public void LoadLevelShiftDraw(EditDirection direction)
	{
		if (this.editInfo.Count <= 0)
		{
			return;
		}
		for (int i = 0; i < this.editInfo.Count; i++)
		{
			if (this.editInfo[i].boardWidget != null)
			{
				UnityEngine.Object.Destroy(this.editInfo[i].boardWidget.gameObject);
			}
			if (this.editInfo[i].hinderWidget != null)
			{
				UnityEngine.Object.Destroy(this.editInfo[i].hinderWidget.gameObject);
			}
		}
		for (int j = 0; j < this.editInfo.Count; j++)
		{
			if (direction == EditDirection.LEFT)
			{
				this.editInfo[j].point = new Point(this.editInfo[j].point.x - 1, this.editInfo[j].point.y);
			}
			else if (direction == EditDirection.RIGHT)
			{
				this.editInfo[j].point = new Point(this.editInfo[j].point.x + 1, this.editInfo[j].point.y);
			}
			else if (direction == EditDirection.UP)
			{
				this.editInfo[j].point = new Point(this.editInfo[j].point.x, this.editInfo[j].point.y + 1);
			}
			else if (direction == EditDirection.DOWN)
			{
				this.editInfo[j].point = new Point(this.editInfo[j].point.x, this.editInfo[j].point.y - 1);
			}
			Vector3 vector = BlocksCoordinate.coordinate.editCoordinate.PuzzleToWorld((float)this.editInfo[j].point.x, (float)this.editInfo[j].point.y);
			vector.z = 0f;
			bool isUp = (this.editInfo[j].point.x + this.editInfo[j].point.y) % 2 == 0;
			int tangramIndex = (this.editInfo[j].point.x + ((this.editInfo[j].point.y % 2 != 0) ? 2 : 0)) % 4;
			if (this.editInfo[j].isHinder)
			{
				HinderWidgetHandler hinderWidgetHandler = Widget.Create<HinderWidgetHandler>();
				hinderWidgetHandler.transform.parent = this.boardBg.transform;
				hinderWidgetHandler.transform.localPosition = vector;
				hinderWidgetHandler.transform.localScale = Vector3.one * BlocksCoordinate.coordinate.editCoordinate.size;
				hinderWidgetHandler.SetData(isUp, tangramIndex);
				hinderWidgetHandler.name = "hinder";
				this.editInfo[j].hinderWidget = hinderWidgetHandler;
			}
			else
			{
				BoardWidgetHandler boardWidgetHandler = Widget.Create<BoardWidgetHandler>();
				boardWidgetHandler.transform.parent = this.boardBg.transform;
				boardWidgetHandler.transform.localPosition = vector + Vector3.back * 1f;
				boardWidgetHandler.transform.localScale = Vector3.one * BlocksCoordinate.coordinate.editCoordinate.size;
				boardWidgetHandler.SetData(isUp, this.editInfo[j].point, new byte[2], this.editInfo[j].color, true);
				boardWidgetHandler.name = "board";
				this.editInfo[j].boardWidget = boardWidgetHandler;
			}
		}
	}

	public void SetRandomBoard(int min, int max, int blockcount)
	{
		this.ReSet();
		int num = UnityEngine.Random.Range(min * blockcount, max * blockcount + 1);
		int x = BlocksCoordinate.coordinate.editCoordinate.width / 2;
		int y = BlocksCoordinate.coordinate.editCoordinate.height / 2;
		this.SetRandomOneBoard(new Point(x, y));
		for (int i = 0; i < num; i++)
		{
			int index = UnityEngine.Random.Range(0, this.editInfo.Count);
			List<Point> neighborPoints = this.GetNeighborPoints(this.editInfo[index].point);
			if (neighborPoints.Count > 0)
			{
				this.SetRandomOneBoard(neighborPoints[UnityEngine.Random.Range(0, neighborPoints.Count)]);
			}
			else
			{
				i--;
			}
		}
		this.UpdateCurrentTileCount();
	}

	private void SetRandomOneBoard(Point point)
	{
		bool isUp = (point.x + point.y) % 2 == 0;
		Vector3 a = BlocksCoordinate.coordinate.editCoordinate.PuzzleToWorld((float)point.x, (float)point.y);
		BoardWidgetHandler boardWidgetHandler = Widget.Create<BoardWidgetHandler>();
		boardWidgetHandler.transform.parent = this.boardBg.transform;
		boardWidgetHandler.transform.localPosition = a + Vector3.back * 1f;
		boardWidgetHandler.transform.localScale = Vector3.one * BlocksCoordinate.coordinate.editCoordinate.size;
		boardWidgetHandler.SetData(isUp, point, new byte[2], -1, true);
		boardWidgetHandler.name = "board";
		EditDrawCtrl.EditInfo editInfo = new EditDrawCtrl.EditInfo();
		editInfo.point = point;
		editInfo.isHinder = false;
		editInfo.color = -1;
		editInfo.boardWidget = boardWidgetHandler;
		this.editInfo.Add(editInfo);
	}

	private List<Point> GetNeighborPoints(Point point)
	{
		List<Point> list = new List<Point>();
		bool flag = (point.x + point.y) % 2 == 0;
		if (!flag && point.y + 1 < BlocksCoordinate.coordinate.editCoordinate.height && this.editInfo.FindIndex((EditDrawCtrl.EditInfo item) => item.point == new Point(point.x, point.y + 1)) < 0)
		{
			list.Add(new Point(point.x, point.y + 1));
		}
		if (flag && point.y - 1 >= 0 && this.editInfo.FindIndex((EditDrawCtrl.EditInfo item) => item.point == new Point(point.x, point.y - 1)) < 0)
		{
			list.Add(new Point(point.x, point.y - 1));
		}
		if (point.x + 1 < BlocksCoordinate.coordinate.editCoordinate.width && this.editInfo.FindIndex((EditDrawCtrl.EditInfo item) => item.point == new Point(point.x + 1, point.y)) < 0)
		{
			list.Add(new Point(point.x + 1, point.y));
		}
		if (point.x - 1 >= 0 && this.editInfo.FindIndex((EditDrawCtrl.EditInfo item) => item.point == new Point(point.x - 1, point.y)) < 0)
		{
			list.Add(new Point(point.x - 1, point.y));
		}
		return list;
	}

	public int[][] GetBoard()
	{
		List<EditDrawCtrl.EditInfo> list = new List<EditDrawCtrl.EditInfo>();
		for (int i = 0; i < this.editInfo.Count; i++)
		{
			list.Add(new EditDrawCtrl.EditInfo
			{
				point = new Point(this.editInfo[i].point.x, this.editInfo[i].point.y),
				isHinder = this.editInfo[i].isHinder,
				color = this.editInfo[i].color
			});
		}
		int num = 9999;
		int num2 = -9999;
		int num3 = 9999;
		int num4 = -9999;
		for (int j = 0; j < this.editInfo.Count; j++)
		{
			if (this.editInfo[j].point.x < num)
			{
				num = this.editInfo[j].point.x;
			}
			if (this.editInfo[j].point.x > num2)
			{
				num2 = this.editInfo[j].point.x;
			}
			if (this.editInfo[j].point.y < num3)
			{
				num3 = this.editInfo[j].point.y;
			}
			if (this.editInfo[j].point.y > num4)
			{
				num4 = this.editInfo[j].point.y;
			}
		}
		Vector3 vector = BlocksCoordinate.coordinate.editCoordinate.PuzzleToWorld((float)num, 0f);
		Vector3 vector2 = BlocksCoordinate.coordinate.editCoordinate.PuzzleToWorld((float)(num + 1), 0f);
		if (vector.y > vector2.y)
		{
			for (int k = 0; k < list.Count; k++)
			{
				if (list[k].point.x % 2 != 0)
				{
					list[k].point = new Point(list[k].point.x, list[k].point.y + 1);
				}
			}
			num = 9999;
			num2 = -9999;
			num3 = 9999;
			num4 = -9999;
			for (int l = 0; l < list.Count; l++)
			{
				if (list[l].point.x < num)
				{
					num = list[l].point.x;
				}
				if (list[l].point.x > num2)
				{
					num2 = list[l].point.x;
				}
				if (list[l].point.y < num3)
				{
					num3 = list[l].point.y;
				}
				if (list[l].point.y > num4)
				{
					num4 = list[l].point.y;
				}
			}
		}
		this.width = num2 - num + 1;
		this.height = num4 - num3 + 1;
		this.board = new int[this.width][];
		this.boardColor = new int[this.width][];
		for (int m = 0; m < this.width; m++)
		{
			this.board[m] = new int[this.height];
			this.boardColor[m] = new int[this.height];
			for (int n = 0; n < this.height; n++)
			{
				Point point = new Point(m + num, n + num3);
				int num5 = list.FindIndex((EditDrawCtrl.EditInfo item) => item.point == point);
				if (num5 >= 0 && !list[num5].isHinder)
				{
					this.board[m][n] = 0;
					this.boardColor[m][n] = list[num5].color;
				}
				else if (num5 >= 0 && list[num5].isHinder)
				{
					this.board[m][n] = -2;
					this.boardColor[m][n] = -1;
				}
				else
				{
					this.board[m][n] = -1;
					this.boardColor[m][n] = -1;
				}
			}
		}
		return this.board;
	}

	public Point GetMinPoint()
	{
		int num = 9999;
		int num2 = 9999;
		for (int i = 0; i < this.editInfo.Count; i++)
		{
			if (this.editInfo[i].point.x < num)
			{
				num = this.editInfo[i].point.x;
			}
			if (this.editInfo[i].point.y < num2)
			{
				num2 = this.editInfo[i].point.y;
			}
		}
		return new Point(num, num2);
	}

	public bool IsReverse()
	{
		int num = 9999;
		int num2 = 9999;
		for (int i = 0; i < this.editInfo.Count; i++)
		{
			if (this.editInfo[i].point.x < num)
			{
				num = this.editInfo[i].point.x;
			}
			if (this.editInfo[i].point.y < num2)
			{
				num2 = this.editInfo[i].point.y;
			}
		}
		return (num + num2) % 2 != 0;
	}

	public int[][] GetBoardColor()
	{
		return this.boardColor;
	}

	public void ReSet()
	{
		for (int i = 0; i < this.editInfo.Count; i++)
		{
			if (this.editInfo[i].boardWidget != null)
			{
				UnityEngine.Object.Destroy(this.editInfo[i].boardWidget.gameObject);
			}
			if (this.editInfo[i].hinderWidget != null)
			{
				UnityEngine.Object.Destroy(this.editInfo[i].hinderWidget.gameObject);
			}
		}
		this.editInfo.Clear();
		this.UpdateCurrentTileCount();
	}

	public void ReSetBoard()
	{
		for (int i = 0; i < this.editInfo.Count; i++)
		{
			if (this.editInfo[i].boardWidget != null)
			{
				UnityEngine.Object.Destroy(this.editInfo[i].boardWidget.gameObject);
			}
			if (this.editInfo[i].hinderWidget != null)
			{
				UnityEngine.Object.Destroy(this.editInfo[i].hinderWidget.gameObject);
			}
		}
		this.editInfo.Clear();
		for (int j = 0; j < this.defaultboardWidgets.Count; j++)
		{
			UnityEngine.Object.Destroy(this.defaultboardWidgets[j].gameObject);
		}
		this.defaultboardWidgets.Clear();
		this.DefaultBoardMake();
		this.UpdateCurrentTileCount();
	}

	public void DebugBoard()
	{
		string text = string.Empty;
		for (int i = this.height - 1; i >= 0; i--)
		{
			text += "\n";
			for (int j = 0; j < this.width; j++)
			{
				text = text + this.board[j][i] + " ";
			}
		}
		UnityEngine.Debug.Log(text);
	}

	public void UpdateCurrentTileCount()
	{
		int num = 0;
		for (int i = 0; i < this.editInfo.Count; i++)
		{
			if (this.editInfo[i] != null && !this.editInfo[i].isHinder)
			{
				num++;
			}
		}
		string obj = "Tile : " + num;
		if (this.onUpdateTileCount != null)
		{
			this.onUpdateTileCount(obj);
		}
	}

	[HideInInspector]
	public int[][] board;

	[HideInInspector]
	public int[][] boardColor;

	public GameObject bottomPosition;

	public GameObject topPosition;

	public Camera viewCamera;

	public GameObject boardBg;

	public GameObject defualtboardBg;

	private List<BoardWidgetHandler> defaultboardWidgets = new List<BoardWidgetHandler>();

	public Action<string> onUpdateTileCount;

	public MeshFilter[] filters;

	public GameObject[] colorObjs;

	private int currentColor = -1;

	private List<EditDrawCtrl.EditInfo> editInfo = new List<EditDrawCtrl.EditInfo>();

	private int width;

	private int height;

	public Point point = default(Point);

	public bool isHinder;

	public BoardWidgetHandler boardWidget;

	public HinderWidgetHandler hinderWidget;

	private class EditInfo
	{
		public Point point = default(Point);

		public int color = -1;

		public bool isHinder;

		public BoardWidgetHandler boardWidget;

		public HinderWidgetHandler hinderWidget;
	}
}
